package com.xiaoyu.awakening.gateway.enums;

import org.springframework.http.HttpStatus;

/**
 * token 解析检验状态
 *
 * @author wangxiaoyu
 * @since v1.0
 */
public enum TokenValidateStatus implements ITokenValidate {
    // token 为空
    TOKEN_EMPTY(0, HttpStatus.UNAUTHORIZED.value(), "token", "token为空"),
    // token 解析错误
    TOKEN_PARSE_ERROR(1, HttpStatus.UNAUTHORIZED.value(), "jwt", "jwt解析失败"),
    // token 格式校验非法
    TOKEN_VALIDATE_INVALID(3, HttpStatus.UNAUTHORIZED.value(), "jwt", "jwt校验失败"),
    // token 格式校验通过;
    TOKEN_PASS(4, HttpStatus.OK.value(), "token", "token解析验证通过"),
    // token 转化为tokenUser错误
    TOKEN_TRANS_TOKENUSER_ERROR(5, HttpStatus.UNAUTHORIZED.value(), "jwt", "jwt校验失败"),
    TOKEN_TRANS_TOKENUSER_OK(6, HttpStatus.UNAUTHORIZED.value(), "invalid token", "");


    private final Integer validateStatus;
    private final Integer httpStatus;
    private final String cause;
    private final String details;

    TokenValidateStatus(Integer validateStatus, Integer httpStatus, String cause, String details) {
        this.validateStatus = validateStatus;
        this.httpStatus = httpStatus;
        this.cause = cause;
        this.details = details;
    }

    @Override
    public Integer getValidateStatus() {
        return this.validateStatus;
    }

    @Override
    public Integer getHttpStatus() {
        return this.httpStatus;
    }

    @Override
    public String getCause() {
        return this.cause;
    }

    @Override
    public String getDetail() {
        return this.details;
    }

    @Override
    public String getPhase() {
        return "TOKEN_FORMAT_VALIDATE";
    }
}
